<?php
include("../WeSql/widget.php");
include("../WeSql/config.php");
include("../WeSql/WeSql.php");
include "api.php";
//admin	user	pass	qq	mail	money	ip	time

/**
 * @var $key
 * @var $config
 */

@$user = $_REQUEST['user'];
@$pass = $_REQUEST['pass'];
$weSql = new WeSql($config);

isIpBlack($weSql,getIP());//检测ip是否被拉黑

if($user!="" and $pass!=""){
    if($weSql->isSelectField("user",[
        "user" => $user
    ])){
        isUserBlack($weSql,$user);//是否为黑名单

        if (decrypt($key,$weSql->select("user","user=${user}")['pass']) == $pass){
            $code = 1;
            $msg = "登录成功";
            $exception = "";
        }else{
            $code = -1;
            $msg = "密码错误";
            $exception = "密码错误";
        }
    }else{
        $code = -1;
        $msg = "账号不存在";
        $exception = "数据库里信息找不到该记录账号";
    }
}else{
    $code = -1;
    $msg = "不能留空";
    $exception = "出现了参数为空的情况！";
}
@$result = [
    "code" => $code,
    "msg" => $msg,
    "exception" => $exception
];
echo json_encode($result,JSON_UNESCAPED_UNICODE);

